Skip to content

feat: support factory-based extension widgets - #359

Open
kaiwishc wants to merge 1 commit into
agegr:mainfrom
kaiwishc:feat/factory-extension-widgets
Open

feat: support factory-based extension widgets#359
kaiwishc wants to merge 1 commit into
agegr:mainfrom
kaiwishc:feat/factory-extension-widgets

Conversation

@kaiwishc

@kaiwishc kaiwishc commented Aug 2, 2026

Copy link
Copy Markdown

Summary

pi-web now supports extension widgets registered as factories, alongside the existing string[] widget API. A factory creates a component through the headless TUI facade, and each render is sent to the browser through the existing extension UI event path.

For a concrete example, @juicesharp/rpiv-todo adds a todo panel above Pi's input box. It registers that panel as a factory: the factory gives Pi a small component that can render the current task list at whatever width is available. When the agent updates a task, the extension asks the component to render again instead of replacing the widget with a new array of strings. pi-web now supports that same pattern, so the live todo panel can be rendered in the browser as the task list changes.

The wrapper also cleans up widget components when they are replaced, cleared, reloaded, or destroyed. Stale render callbacks are ignored. If a factory or render fails, the widget is cleared and the error is reported as extension_error.

Testing

  • Added seven Node tests for existing string[] compatibility, initial and subsequent renders, cleanup, error handling, reload and destroy behavior, and command-context reloads.
  • node --test lib/rpc-manager-widgets.test.mjs
  • node_modules/.bin/tsc --noEmit
  • npm run lint

Scope

This PR changes the runtime support for factory-based widgets. It does not change where widgets appear in the browser; that layout change is covered separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant